<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        // var name = "The Window";

        // var object = {
        //     name: "My Object",

        //     getNameFunc: function () {
        //         var that = this;
        //         return function () {
        //             return that.name;
        //         };

        //     }

        // };

        // alert(object.getNameFunc()());
        // setTimeout(() => {
        //     console.log(1)
        // }, 0)

        // new Promise((resolve, reject) => {
        //     console.log(2)
        //     resolve('p1')
        //     new Promise((resolve, reject) => {
        //         console.log(3)
        //         setTimeout(() => {
        //             resolve('setTimeout2')
        //             console.log(4)
        //         }, 0)
        //         resolve('p2')
        //     }).then(data => {
        //         console.log(data)
        //     })
        //     new Promise((resolve, reject) => {
        //         console.log(8)
        //         setTimeout(() => {
        //             resolve('setTimeout2')
        //             console.log(9)
        //         }, 0)
        //         resolve('p3')
        //     }).then(data => {
        //         console.log(data)
        //     })

        //     setTimeout(() => {
        //         resolve('setTimeout1')
        //         console.log(5)
        //     }, 0)
        // }).then(data => {
        //     console.log(data)
        // })

        // console.log(6)
        // 2,3,8，6,p3,p2,p1,1,4,9,5
        async function async1() {
            console.log('async1 start')
            await async2()
            console.log('async1 end')
        }
        async function async2() {
            console.log('async2')
        }
        console.log('script start')
        setTimeout(function () {
            console.log('setTimeout')
        }, 0)
        async1();
        new Promise(function (resolve) {
            console.log('promise1')
            resolve();
        }).then(function () {
            console.log('promise2')
        })
        console.log('script end')
        // script start
        // async1 start
        // async2
        // async1 end
        // promise1
        // script end
        // promise2
        // setTimeout
    </script>
</body>

</html>